<!DOCTYPE html>
<html>
<head>
  <title>@yield('title', 'Weibo APP')——基于Laravel的微博应用</title>
  <meta name="csrf-token" content="{{ csrf_token() }}">
  <link rel="stylesheet" href="/layui/css/layui.css">
  <link rel="stylesheet" href="/weibo/weibo.css">
</head>
<body class="layui-layout-body">
  <div class="layui-layout layui-layout-admin">
    @include('layouts._header')
    <div class="layui-body" style="left: 0px;">
      <!-- 内容主体区域 -->
      @yield('content')
      @include('layouts._footer')
    </div>
  </div>

  <script type="text/javascript" src="/layui/layui.js"></script>
  <script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use(['layer', 'element'], function(){
      var element = layui.element;
      var $ = layui.jquery;
      $.ajaxSetup({
          headers: {
              'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
          }
      });
      //错误提示
      @if(count($errors)>0)
          @foreach($errors->all() as $error)
              layer.msg("{{$error}}",{icon:2});
              @break
          @endforeach
      @endif

      //一次性正确信息提示
      @foreach (['success', 'info'] as $msg)
        @if(session($msg))
          layer.msg("{{session($msg)}}",{icon:1});
        @endif
      @endforeach

      //一次性错误信息提示
      @foreach (['danger', 'warning'] as $msg)
        @if(session($msg))
          layer.msg("{{session($msg)}}",{icon:2});
        @endif
      @endforeach
    });
  </script>
  @yield('js')
</body>
</html>
